﻿namespace UDKDevKitVSXShell.MainPackage
{
    using System;
    using System.Runtime.InteropServices;

    [Guid("9347634D-E2C4-4A67-848E-E4DB0B08B863")]
    public interface SMyGoogleAnalitics { }

    [Guid("5601B802-41CD-4448-80DD-F95740ACCB66")]
    [ComVisible(false)]
    public interface IMyGoogleAnalitics
    {
        void TrackEvent(string @object, string action, string label, int value);
        void Save(bool ifDirty);
    }

    public class GoogleAnalitics
    {
        private static IMyGoogleAnalitics myGoogleAnalitics;

        public static void Init(IServiceProvider provider)
        {
            if (provider == null)
            {
                return;
            }

            myGoogleAnalitics = provider.GetService(typeof(SMyGoogleAnalitics)) as IMyGoogleAnalitics;
        }

        public static void TrackEvent(string @object, string action, string label, int value)
        {
            if (myGoogleAnalitics == null)
            {
                return;
            }

            myGoogleAnalitics.TrackEvent(@object, action, label, value);
        }
    }
}
